package cn.le.io;

/**
 * FileChannel是Java NIO中的一个连接文件的通道,可以通过文件通道读写文件
 *  FileChannel无法设置为非阻塞模式,它总是运行在阻塞的模式下
 *
 */
public class GetChannel {

    public static void main(String[] args) {
        String sql = "select s.brokerid brokerid, " +
                "s.name, " +
                "nvl(sum(s.sumTradeFee), 0) sumTradeFee, " +
                "nvl(sum(s.sumBrokereachdivide), 0) sumBrokereachdivide, " +
                "nvl(sum(s.sumReward), 0) sumReward, " +
                "nvl(sum(s.sumSelfGain), 0) sumSelfGain, " +
                "nvl(sum(s.sumMarhetGain), 0) sumMarhetGain, " +
                "nvl(sum(s.sumFinalMarhetGain), 0) sumFinalMarhetGain " +
                "from (select"
                + " a.rewardtype rewardtype,"
                + // 模块
                " a.brokerid brokerid, "
                + // 1、授权机构代码
                "a.breedid breedid,"
                + // 品种ID
                " (select name from br_broker where brokerid=a.brokerid) name,"
                + // 2、授权机构名称
                " a.firmid firmid,"
                + // 3、交易商代码
                " (select name from m_firm where firmid=a.firmid) firmname,"
                + // 4、交易商名称
                " a.cleardate cleardate,"
                + " a.sTradeFee sumTradeFee,"
                + // 5、手续费
                " a.sBrokereachdivide sumBrokereachdivide,"
                + // 税前分成
                " a.sReward sumReward,"
                + // 税前实得：加收的手续费+税前分成
                " (a.sReward-a.sBrokereachdivide) sumSelfGain,"
                + // 6、加收的手续费,即授权服务机构手续费
                " (a.sTradeFee-(a.sReward-a.sBrokereachdivide)) sumMarhetGain,"
                + // 7、交易所手续费
                " (a.sTradeFee-a.sReward) sumFinalMarhetGain "
                + // 9、交易所实得手续费
                " from "
                + " (select t.rewardtype rewardtype, (select ta.breedid from t_a_breed ta,t_commodity tc where t.commodityid =tc.commodityid and tc.breedid = ta.breedid) breedid,t.brokerid brokerid,t.firmid firmid,t.cleardate cleardate,sum(nvl(t.reward,0)) sReward,"
                + " sum(nvl(t.brokereachdivide,0)) sBrokereachdivide,sum(nvl((t.reward + t.marketreward),0)) sTradeFee"
                + " from t_br_firmrewarddeail t  group by t.rewardtype, t.firmid,t.brokerid,t.cleardate,t.commodityid) a"
                + " where 1=1) s where 1=1";
        System.out.println(sql);

    }

}
